package com.yan_jiu_sheng.JavaAdvance.d_udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

/**
 * @author yulongTian
 * @create 2024-05-29 22:53
 */
public class Send {
    public static void main(String[] args) throws Exception {
        DatagramSocket socket = new DatagramSocket();
        byte[] bytes = "hello world".getBytes();
        InetAddress ip = InetAddress.getByName("127.0.0.1");
        int port = 6666;
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, ip, port);
        socket.send(dp);
        socket.close();
    }


}
